//
//  WZGOrderPayWechatAlertBottomView.m
//  ZCJZ
//
//  Created by sujeking on 2019/9/19.
//  Copyright © 2019 jeking. All rights reserved.
//

#import "WZGOrderPayWechatAlertBottomView.h"
#import <BlocksKit+UIKit.h>
@interface WZGOrderPayWechatAlertBottomView()

@property (weak, nonatomic) IBOutlet UIButton *leftBtn;
@property (weak, nonatomic) IBOutlet UIButton *rightBtn;

@end


@implementation WZGOrderPayWechatAlertBottomView

- (void)awakeFromNib {
    [super awakeFromNib];
    [self setupSubViews];
}


- (void)setupSubViews {
    self.leftBtn.layer.cornerRadius = 5.0;
    self.leftBtn.layer.masksToBounds = YES;

    self.rightBtn.layer.cornerRadius = 5.0f;
    self.rightBtn.layer.masksToBounds = YES;

    self.leftBtn.layer.borderWidth = 1.0f;
    self.leftBtn.layer.borderColor = [UIColor redColor].CGColor;
    [self.leftBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    self.leftBtn.backgroundColor = [UIColor whiteColor];
    
    [self.rightBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.rightBtn.backgroundColor = [UIColor redColor];

    [self.leftBtn bk_addEventHandler:^(UIButton *sender) {
        if (self.btnClickCallback) {
            self.btnClickCallback(sender.tag);
        }
    } forControlEvents:UIControlEventTouchUpInside];

    [self.rightBtn bk_addEventHandler:^(UIButton *sender) {
        if (self.btnClickCallback) {
            self.btnClickCallback(sender.tag);
        }
    } forControlEvents:UIControlEventTouchUpInside];
}

- (void)setTitles:(NSArray *)titles {
    if (titles == nil || titles.count == 0) {
        return;
    }
    NSInteger count = titles.count;
    if (count == 1) {
        [self.leftBtn setTitle:titles.firstObject forState:UIControlStateNormal];
        self.rightBtn.hidden = YES;
    }
    if (count == 2) {
        self.rightBtn.hidden = NO;
        [self.leftBtn setTitle:titles.firstObject forState:UIControlStateNormal];
        [self.rightBtn setTitle:titles.lastObject forState:UIControlStateNormal];
    }
}

@end
